package com.liuqi.knet.remoting.exchange;

import java.util.concurrent.atomic.AtomicLong;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 发送请求
 *
 * @author liuqi
 * @date 2024/12/17 15:11
 **/
@Getter
@Setter
@ToString
public class Request {

    /**
     * 消息ID, 每次请求进行递增
     */
    private static final AtomicLong INVOKE_ID = new AtomicLong(0);

    /**
     * 消息id
     */
    private final long id;

    /**
     * 双向的, 需要服务端的响应
     */
    private boolean twoWay;

    /**
     * 传输数据
     */
    private Object data;

    public Request() {
        id = INVOKE_ID.getAndIncrement();
    }

    public Request(long id) {
        this.id = id;
    }

    public Request(Object data) {
        this();
        this.data = data;
    }

    public Request(boolean twoWay, Object data) {
        this();
        this.twoWay = twoWay;
        this.data = data;
    }

}
